
/*
class Greeter {
    greeting2: string;
    constructor(message: string) {
        this.greeting2 = message;
    }
    greet() {
        return "Hello, " + this.greeting2;
    }
}

let greeter = new Greeter("world");
 */

class Animal2 {
    move(distanceInMeters: number = 0) {
        console.log(`Animal moved ${distanceInMeters}m.`);
    }
}

class Dog2 extends Animal2 {
    bark() {
        console.log('Woof! Woof!');
    }
}

const dog = new Dog2();
dog.bark();
dog.move(10);
dog.bark();


class Animal4 {
    public name: string;
    public constructor(theName: string) { this.name = theName; }
    public move(distanceInMeters: number) {
        console.log(`${this.name} moved ${distanceInMeters}m.`);
    }
}


class Animal5 {
    private name: string;
    constructor(theName: string) { this.name = theName; }
}

new Animal5("Cat").name; // 错误: 'name' 是私有的.


class Animal8 {
    private name: string;
    constructor(theName: string) { this.name = theName; }
}

class Rhino extends Animal8 {
    constructor() { super("Rhino"); }
}

class Employee {
    private name: string;
    constructor(theName: string) { this.name = theName; }
}

let animal = new Animal8("Goat");
let rhino = new Rhino();
let employee = new Employee("Bob");

animal = rhino;
animal = employee; // 错误: Animal 与 Employee 不兼容.
